package com.suns.util;

import org.apache.commons.lang3.StringUtils;

public class LevelUtil {
    //各层级分隔符
    public final static String SEPARATOR = ".";

    //root 的id
    public final static String ROOT = "0";

    /**
     * 部门level计算规则( 0   0.1    0.1.1    0.1.2  ...   0.5   ...)
     * @param parentLevel
     * @param parentId
     * @return
     */
    public static String calculateLevel(String parentLevel, int parentId) {

        if (StringUtils.isBlank(parentLevel)) {
            return ROOT;
        } else {
            return StringUtils.join(parentLevel,SEPARATOR,parentId);
        }
    }
}
